<template>
	<view class="" style="padding: 0 20rpx;">
		<view v-if="list">
			<view class="list" v-for="item in list">
				<view class="lef">
					<view v-if="item.isdefault ==1"
						style="padding: 5rpx;background-color: blue;color: #fff;display: inline-block;border-radius: 5rpx;font-size: 20rpx;">
						默认
					</view>
					<view>{{item.headtext}}</view>
					<view style="color: #e3e3e3;margin-top: 20rpx;">{{item.type == 1 ? '个人/非企业单位' : '企业'}}</view>
				</view>
				<view class="righ">
					<image src="../../static/images/invoice/del.png" style="width: 36rpx;height: 36rpx;"
						@click="sdel(item.id)"></image>
				</view>
			</view>
		</view>

		<view v-else
			style="color: #e3e3e3;font-size: 26rpx;height: 700rpx;display: flex;justify-content: center;align-items: center;">
			暂无抬头发票
		</view>




		<view class="btn" @click="goto">
			+添加发票抬头
		</view>
	</view>


</template>
<script>
	export default {
		components: {},
		data() {
			return {
				value: 0,
				customStyle: {
					backgroundColor: '#62ed0d',
					color: '#fff'
				},
				list: []
			};
		},
		async onLoad() {
			let res = await this.$api.getmyfh({})
			this.list = res.data

		},
		async onShow() {
			let res = await this.$api.getmyfh({})
			this.list = res.data
		},
		methods: {
			async sdel(id) {
				let res = await this.$api.delmyfh({
					id,
				})
				uni.showToast({
					title: '删除成功！'
				})
				setTimeout(() => {
					this.shuaxin()
				}, 500)


			},
			async shuaxin() {
				let res = await this.$api.getmyfh({})
				this.list = res.data
			},
			goto() {
				uni.navigateTo({
					url: '/subPages/invoice/invoiceTitleEdit'
				})
			}
		},
		mounted() {
			// const timer = setInterval(() => {
			// 	if (this.value >= 199) {
			// 		clearInterval(timer)
			// 		return
			// 	}
			// 	this.value++
			// }, 100)
		}
	};
</script>

<style>
	.btn {
		position: fixed;
		bottom: 20rpx;
		background-color: blue;
		width: 700rpx;
		color: #fff;
		line-height: 80rpx;
		border-radius: 50rpx;
		text-align: center;
		left: 50%;
		transform: translateX(-50%);
	}

	.list {
		margin-bottom: 40rpx;
		border-radius: 15rpx;
		padding: 30rpx;
		background-color: #fff;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
</style>